package com.seveneight.baijiesteward.ui.user.model;

import android.content.Context;

import com.seveneight.baijiesteward.bean.BaseEntity;
import com.seveneight.baijiesteward.bean.OrderBean;
import com.seveneight.baijiesteward.http.BaseModel;
import com.seveneight.baijiesteward.http.BaseObserver;
import com.seveneight.baijiesteward.http.MyCallBack;
import com.seveneight.baijiesteward.http.RetrofitFactory;
import com.seveneight.baijiesteward.ui.user.contract.CreateOderContract;

import okhttp3.RequestBody;

/**
 * Created by user1 on 2018/3/28.
 */

public class CreateOrderModel extends BaseModel implements CreateOderContract.CreateOderModel {
    @Override
    public void createOrder(Context context, RequestBody body, MyCallBack<OrderBean> myCallBack) {
        RetrofitFactory.getInstence().API().createOrder(body).
                compose(this.<BaseEntity<OrderBean>>setThread()).
                subscribe(new BaseObserver<OrderBean>(context) {
                    @Override
                    protected void onSuccees(BaseEntity<OrderBean> t) throws Exception {
                        myCallBack.onSuccess(t.getData());
                    }

                    @Override
                    protected void onFailure(Throwable e, boolean isNetWorkError) throws Exception {

                    }
                });
    }
}
